
***************************************************************************
* Are Consumers' Spending Decisions in Line With an Euler Equation?
* Lena Dräger and Giang Nghiem
* February 2020
**************************************************************************
* This do-file performs the summary statistics and estimations using the Hamburg survey ///
* in the Online Appendix
**************************************************************************

clear

use "Hamburg_Survey_Data_selected.dta", clear

// Set panel dimension

xtset hh_id wave

*Table A1: Summary Statistics of Quantitative Inflation and Interest Rate Expectations

****
set more off

foreach var of varlist  infl_exp_quant infl_perc_quant  {

tabstat `var'  if abs(`var')<=15 , stat(mean median sd min max n) save
matrix out_`var' = r(StatTotal)'

foreach i of varlist male fem age_y age_ml age_mh age_o edu_l edu_m edu_h inc_l inc_ml inc_mh inc_h { //inchh_aver_q1 inchh_aver_q2 inchh_aver_q3 inchh_aver_q4 or hh_inc_l hh_inc_ml hh_inc_mh hh_inc_h
tabstat `var'  if  abs(`var')<=15 & `i'==1 , stat(mean median sd min max n) save
matrix out_`var' = out_`var'\r(StatTotal)'
}

mat rownames out_`var'  =  All Male Female -25 26-45 46-65 66+ Low_Education Medium_Education High_Education L_Income ML_Income MH_Income H_Income // HH_Income<1000 1000<HH_Income<2000 2000<HH_Income<4000 HH_Income>4000 
outtable using stat_`var'_demogr_panel, mat(out_`var') center replace caption("Summary Statistics `var'") nobox f(%12.2fc %12.2fc %12.2fc %12.2fc %12.0fc) clabel(descstat)
*tabout mat(out_`var') using stat_`var'_demogr.xls,  replace
}

foreach var of varlist   int_exp_quant{

tabstat `var'  if `var'<=5 & wave == 1, stat(mean median sd min max n) save
matrix out_`var' = r(StatTotal)'

foreach i of varlist male fem age_y age_ml age_mh age_o edu_l edu_m edu_h inc_l inc_ml inc_mh inc_h { //inchh_aver_q1 inchh_aver_q2 inchh_aver_q3 inchh_aver_q4 or hh_inc_l hh_inc_ml hh_inc_mh hh_inc_h
tabstat `var'  if  `var'<=5 & `i'==1 & wave == 1, stat(mean median sd min max n) save
matrix out_`var' = out_`var'\r(StatTotal)'
}

mat rownames out_`var'  =  All Male Female -25 26-45 46-65 66+ Low_Education Medium_Education High_Education L_Income ML_Income MH_Income H_Income // HH_Income<1000 1000<HH_Income<2000 2000<HH_Income<4000 HH_Income>4000 
outtable using stat_`var'_demogr_panel, mat(out_`var') center replace caption("Summary Statistics `var'") nobox f(%12.2fc %12.2fc %12.2fc %12.2fc %12.0fc) clabel(descstat)
*tabout mat(out_`var') using stat_`var'_demogr.xls,  replace
}

****
****
*Table A2: Demographic Correlations

corr saver2 basic_literacy inc_l inc_ml inc_mh inc_h age_y age_ml age_mh age_o edu_l edu_m edu_h

*******************************************************************************************************
*Estimations	

global demo1 sex age age2 inc_l inc_ml inc_mh edu_h edu_m retired employ_ml employ_mh employ_h risk econ_exp_qual unemp_exp_qual wave

*Table A5: Robustness Check: OLS and OLS with Fixed Effects

estimate clear

reg cons_past cons_fut int_exp_qual infl_exp_qual $demo1 [pweight=weight] if basic_literacy==1  , vce(cluster hh_id)

xtreg cons_past cons_fut int_exp_qual infl_exp_qual $demo1 [pweight=weight] if basic_literacy==1 , fe vce(cluster hh_id)


*Table A6: Testing for a Wave-Specific Effect

qui: oprobit cons_past cons_fut int_exp_qual infl_exp_qual $demo1 [pweight=weight] if wave ==0, vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp_qual) predict(outcome(3)) atmean 

qui: oprobit cons_past cons_fut int_exp_qual infl_exp_qual $demo1 [pweight=weight] if wave ==0 & basic_literacy==1, vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp_qual) predict(outcome(3)) atmean 

qui: oprobit cons_past cons_fut int_exp_qual infl_exp_qual $demo1 [pweight=weight] if wave ==1, vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp_qual) predict(outcome(3)) atmean 

qui: oprobit cons_past cons_fut int_exp_qual infl_exp_qual $demo1 [pweight=weight] if wave ==1 & basic_literacy==1, vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp_qual) predict(outcome(3)) atmean 

 
*Table A7:Income Expectations and Current Consumption

estimate clear

qui: oprobit income_exp_qual cons_fut int_exp_qual infl_exp_qual $demo1   [pweight=weight] if wave==1 & basic_literacy==1 , vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp_qual) predict(outcome(5)) atmean 

qui: oprobit cons_past cons_fut int_exp_qual infl_exp_qual $demo1 [pweight=weight] if wave==1 & basic_literacy==1 , vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp_qual) predict(outcome(3)) atmean 

qui: oprobit cons_past cons_fut int_exp_qual infl_exp_qual income_exp_qual $demo1 [pweight=weight] if wave==1 & basic_literacy==1 , vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp_qual income_exp_qual) predict(outcome(3)) atmean 


*Table A8: Euler Equation with Long-run and House Price Inflation Expectations

estimate clear

qui: oprobit cons_past cons_fut int_exp_qual infl_exp5y_qual $demo1 [pweight=weight], vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp5y_qual) predict(outcome(3)) atmean 

qui: oprobit cons_past cons_fut int_exp_qual infl_immo_qual $demo1 [pweight=weight], vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_immo_qual) predict(outcome(3)) atmean 

qui: oprobit cons_past cons_fut int_exp_qual infl_exp5y_qual $demo1  [pweight=weight] if basic_literacy==1, vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp5y_qual) predict(outcome(3)) atmean 

qui: oprobit cons_past cons_fut int_exp_qual infl_immo_qual $demo1  [pweight=weight] if basic_literacy==1, vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_immo_qual) predict(outcome(3)) atmean 


*Table A9: Estimation with Categorical Dummies for Qualitative Expectations

estimate clear

qui: oprobit cons_past cons_fut i.int_exp_qual i.infl_exp_qual $demo1 [pweight=weight] , vce(cluster hh_id)
estpost margins, dydx(cons_fut infl_exp_qual int_exp_qual) predict(outcome(3)) 

qui: oprobit cons_past cons_fut i.int_exp_qual i.infl_exp_qual $demo1 [pweight=weight] if basic_literacy==1, vce(cluster hh_id)
estpost margins, dydx(cons_fut infl_exp_qual int_exp_qual) predict(outcome(3)) 


*Table A10: Excluding Expected Inflation Rates Which Are Multiples of 5

gen infl_exp_quant5 = infl_exp_quant
replace infl_exp_quant5 =. if infl_exp_quant5 ==5
replace infl_exp_quant5 =. if infl_exp_quant5 ==10
replace infl_exp_quant5 =. if infl_exp_quant5 ==15

estimate clear

qui: oprobit cons_past cons_fut int_exp_qual infl_exp_quant5 $demo1 [pweight=weight] if abs(infl_exp_quant)<=15 & abs(infl_perc_quant)<=15 , vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp_quant5) predict(outcome(3)) atmean 

qui: oprobit cons_past cons_fut int_exp_qual infl_exp_quant5 $demo1 [pweight=weight] if abs(infl_exp_quant)<=15 & abs(infl_perc_quant)<=15 & basic_literacy==1, vce(cluster hh_id)
estpost margins, dydx(cons_fut int_exp_qual infl_exp_quant5) predict(outcome(3)) atmean 


*Table A11: Euler Equation with the Readiness to Spend on Durables, Using Inflation Perceptions as Instruments for Inflation Expectations

estimate clear

qui: reg infl_exp_qual infl_perc_qual  cons_durfut int_exp_qual  $demo1 [pweight=weight] , vce(cluster hh_id) 
te infl_perc_qual
predict uhat, resid
qui: oprobit climate_cons cons_durfut int_exp_qual infl_exp_qual uhat $demo1 [pweight=weight]  , vce(cluster hh_id)
estpost margins, dydx(cons_durfut int_exp_qual infl_exp_qual) predict(outcome(3)) atmean 
drop uhat


qui: reg  infl_exp_quant infl_perc_quant cons_durfut int_exp_qual  $demo1 [pweight=weight] if abs(infl_exp_quant)<=15 & abs(infl_perc_quant)<=15 , vce(cluster hh_id) 
te infl_perc_quant
predict uhat, resid
qui: oprobit climate_cons cons_durfut int_exp_qual infl_exp_quant uhat $demo1 [pweight=weight] if abs(infl_exp_quant)<=15 & abs(infl_perc_quant)<=15 , vce(cluster hh_id)
estpost margins, dydx(cons_durfut int_exp_qual infl_exp_quant) predict(outcome(3)) atmean 
drop uhat

qui: reg infl_exp_qual infl_perc_qual cons_durfut int_exp_qual  $demo1 [pweight=weight] if basic_literacy==1, vce(cluster hh_id) 
te infl_perc_qual
predict uhat, resid
qui: oprobit climate_cons cons_durfut int_exp_qual infl_exp_qual uhat $demo1  [pweight=weight] if basic_literacy==1 , vce(cluster hh_id)
estpost margins, dydx(cons_durfut int_exp_qual infl_exp_qual) predict(outcome(3)) atmean 
drop uhat


qui: reg  infl_exp_quant infl_perc_quant cons_durfut  int_exp_qual  $demo1 [pweight=weight] if abs(infl_exp_quant)<=15 & abs(infl_perc_quant)<=15 & basic_literacy==1 , vce(cluster hh_id) 
te infl_perc_quant
predict uhat, resid
qui: oprobit climate_cons cons_durfut  int_exp_qual infl_exp_quant uhat $demo1 [pweight=weight] if abs(infl_exp_quant)<=15 & abs(infl_perc_quant)<=15 & basic_literacy==1, vce(cluster hh_id)
estpost margins, dydx(cons_durfut  int_exp_qual infl_exp_quant) predict(outcome(3)) atmean 
drop uhat

*Table A12: Euler Equation with the Readiness to Spend on Durables, Multiple Measurement Approach
estimate clear

qui: reg infl_exp_qual infl_exp_quant cons_durfut int_exp_qual  $demo1 [pweight=weight] if abs(infl_exp_quant)<=15, vce(cluster hh_id) 
te infl_exp_quant
predict uhat, resid
qui: oprobit climate_cons cons_durfut int_exp_qual infl_exp_qual uhat $demo1 [pweight=weight]  if abs(infl_exp_quant)<=15, vce(cluster hh_id)
estpost margins, dydx(cons_durfut int_exp_qual infl_exp_qual) predict(outcome(3)) atmean 
drop uhat

qui: reg  infl_exp_quant infl_exp_qual cons_durfut int_exp_qual  $demo1 [pweight=weight] if abs(infl_exp_quant)<=15  , vce(cluster hh_id) 
te infl_exp_qual
predict uhat, resid
qui: oprobit climate_cons cons_durfut int_exp_qual infl_exp_quant uhat $demo1 [pweight=weight] if abs(infl_exp_quant)<=15  , vce(cluster hh_id)
estpost margins, dydx(cons_durfut int_exp_qual infl_exp_quant) predict(outcome(3)) atmean 
drop uhat

qui: reg infl_exp_qual infl_exp_quant  cons_durfut int_exp_qual  $demo1 [pweight=weight] if abs(infl_exp_quant)<=15 & basic_literacy==1, vce(cluster hh_id) 
te infl_exp_quant
predict uhat, resid
qui: oprobit climate_cons cons_durfut int_exp_qual infl_exp_qual uhat $demo1  [pweight=weight] if abs(infl_exp_quant)<=15 & basic_literacy==1 , vce(cluster hh_id)
estpost margins, dydx(cons_durfut int_exp_qual infl_exp_qual) predict(outcome(3)) atmean 
drop uhat


qui: reg  infl_exp_quant infl_exp_qual cons_durfut  int_exp_qual  $demo1 [pweight=weight] if abs(infl_exp_quant)<=15  & basic_literacy==1 , vce(cluster hh_id) 
te infl_exp_qual
predict uhat, resid
qui: oprobit climate_cons cons_durfut  int_exp_qual infl_exp_quant uhat $demo1 [pweight=weight] if abs(infl_exp_quant)<=15  & basic_literacy==1, vce(cluster hh_id)
estpost margins, dydx(cons_durfut  int_exp_qual infl_exp_quant) predict(outcome(3)) atmean 
drop uhat


*Figure A1-A8: Heterogeneous Effects of Inflation Expectations and Interest Rate Expectations Across Socio-Demographic Groups and Financial Market Participation

estimate clear

*Heterogenous effects 

global demo2 sex age age2 income_group2 edu_h edu_m retired employ_ml employ_mh employ_h risk econ_exp_qual unemp_exp_qual wave

local demo	"edu_h income_group2 age_group2 sex basic_literacy saver2 fin_par mort"
foreach x of local demo {
local y : variable label `x'
	qui: oprobit cons_past cons_fut c.int_exp_qual##i.`x' c.infl_exp_qual##i.`x' $demo2 [pweight=weight], vce(cluster hh_id)
	qui: margins `x' , dydx(infl_exp_qual) predict(outcome(3)) 
	marginsplot, level(90) ytitle("") xtitle("`y'")  graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) title("Marginal Effect of Inflation Expectation")
	graph export inflexp_`x'.pdf, as(pdf) replace
		}
		
local demo	" edu_h income_group2 age_group2 sex basic_literacy saver2 fin_par mort"
foreach x of local demo {
local y : variable label `x'
	qui: oprobit cons_past cons_fut c.int_exp_qual##i.`x' c.infl_exp_qual##i.`x' $demo2 [pweight=weight], vce(cluster hh_id)
	qui: margins `x' , dydx(int_exp_qual) predict(outcome(3)) 
	marginsplot, level(90) ytitle("") xtitle("`y'")  graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) title("Marginal Effect of Interest rate Expectation")
	graph export intexp_`x'.pdf, as(pdf) replace	
		}
		
		***********

*Figure A9: News Effects: Male vs. Female

**Sex

*Monetary news

qui: oprobit cons_past cons_fut i.news_monetary##c.int_exp_qual##i.sex i.news_monetary##c.infl_exp_qual##i.sex $demo1  [pweight=weight], vce(cluster hh_id)
qui: margins news_monetary, dydx(infl_exp_qual) predict(outcome(3)) by(sex)
marginsplot, by(sex) level(90) ytitle("") xtitle("Monetary news")  graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) title(" ") 


*Finance news
qui: oprobit cons_past cons_fut i.news_finance##c.int_exp_qual##i.sex i.news_finance##c.infl_exp_qual##i.sex $demo1 [pweight=weight] , vce(cluster hh_id)
qui: margins news_finance, dydx(int_exp_qual) predict(outcome(3)) by(sex)
marginsplot, by(sex) level(90) ytitle("") xtitle("Financial news")  graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) title(" ") 


*Figure A10: News Effects: Low vs. High Income

global demo2 sex age age2 income_group2 edu_h edu_m retired employ_ml employ_mh employ_h risk econ_exp_qual unemp_exp_qual wave

*income_group2

*Monetary news

qui: oprobit cons_past cons_fut i.news_monetary##c.int_exp_qual##i.income_group2 i.news_monetary##c.infl_exp_qual##i.income_group2 $demo2 [pweight=weight], vce(cluster hh_id)
qui: margins news_monetary, dydx(infl_exp_qual) predict(outcome(3)) by(income_group2)
marginsplot, by(income_group2) level(90) ytitle("") xtitle("Monetary news")  graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) title(" ") 

*Finance news
qui: oprobit cons_past cons_fut i.news_finance##c.int_exp_qual##i.income_group2 i.news_finance##c.infl_exp_qual##i.income_group2 $demo2 [pweight=weight], vce(cluster hh_id)
qui: margins news_finance, dydx(int_exp_qual) predict(outcome(3)) by(income_group2)
marginsplot, by(income_group2) level(90) ytitle("") xtitle("Financial news")  graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) title(" ") 

*Figure A11: News Effects: Financial Market Participation

*Financial market participant

*Monetary news

qui: oprobit cons_past cons_fut i.news_monetary##c.int_exp_qual##i.fin_par i.news_monetary##c.infl_exp_qual##i.fin_par $demo1 [pweight=weight], vce(cluster hh_id)
qui: margins news_monetary, dydx(infl_exp_qual) predict(outcome(3)) by(fin_par)
marginsplot, by(fin_par) level(90) ytitle("") xtitle("Monetary news")  graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) title(" ") 

*Finance news
qui: oprobit cons_past cons_fut i.news_finance##c.int_exp_qual##i.fin_par i.news_finance##c.infl_exp_qual##i.fin_par $demo1 [pweight=weight], vce(cluster hh_id)
qui: margins news_finance, dydx(int_exp_qual) predict(outcome(3)) by(fin_par)
marginsplot, by(fin_par) level(90) ytitle("") xtitle("Financial news")  graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) title(" ") 


*Figure A11: News Effects: Mortage owner

**Credit vs. non credit owners

*Monetary news

qui: oprobit cons_past cons_fut i.news_monetary##c.int_exp_qual##i.mort_new i.news_monetary##c.infl_exp_qual##i.mort_new $demo1 [pweight=weight], vce(cluster hh_id)
qui: margins news_monetary, dydx(infl_exp_qual) predict(outcome(3)) by(mort_new)
marginsplot, by(mort_new) level(90) ytitle("") xtitle("Monetary news")  graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) title(" ") 

*Finance news
qui: oprobit cons_past cons_fut i.news_finance##c.int_exp_qual##i.mort_new i.news_finance##c.infl_exp_qual##i.mort_new $demo1 [pweight=weight], vce(cluster hh_id)
qui: margins news_finance, dydx(int_exp_qual) predict(outcome(3)) by(mort_new)
marginsplot, by(mort_new) level(90) ytitle("") xtitle("Financial news")  graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) plotregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white)) title(" ") 


************************************************************







